<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>计划执行-计划调整详情页面</title>
    <script src="/scripts/boot.js"></script>
    <link href="/scripts/daterangepicker/js/daterangepicker.min.css" rel="stylesheet" type="text/css" />
    <script src="/scripts/daterangepicker/js/moment.js" type="text/javascript"></script>
    <script src="/scripts/daterangepicker/js/jquery.daterangepicker.min.js" type="text/javascript"></script>
    <script src="/scripts/daterangepicker/ux.daterangepicker.js" type="text/javascript"></script>
    <link href="/scripts/daterangepicker/css/skin.css" rel="stylesheet" type="text/css" />
    <!--//上传插件-->
    <link href="/scripts/webuploader/css/webuploader.css" rel="stylesheet" type="text/css" />
    <link href="/scripts/webuploader/css/style.css" rel="stylesheet" type="text/css" />
    <script src="/scripts/webuploader/js/webuploader.js"></script>
    <script src="/scripts/webuploader/js/upload.js"></script>
    <style>
        html body .searchbox .mini-buttonedit-icon
        {
            /*background:url(static/scripts/daterangepicker/search.gif) no-repeat 50% 50%;*/
        }
        .rangeHidden{
            display: none;
        }
    </style>
</head>
<body class="bg-white">
<div id="editForm">
    <div class="title-info mb-20"><span>计划信息</span></div>
    <table class="editTable table-bg" border="0" cellpadding="1" cellspacing="1" style="width:100%;table-layout:fixed;">
        <colgroup>
            <col width="150px"></col>
            <col width="50%"></col>
            <col width="150px"></col>
            <col width="50%"></col>
        </colgroup>

        <tr>
            <td class="text-titlebg">
                所属项目
            </td>
            <td >
                <div class="color-66 input-div" id="itemName"></div>
            </td>
            <td class="text-titlebg">
                项目计划
            </td>
            <td >
                <div class="color-66 input-div" id="planName"></div>
            </td>
        </tr>
        <tr>
            <td class="text-titlebg">
                所属类别
            </td>
            <td>
                <div class="color-66 input-div" id="planTypeName"></div>
            </td>
            <td class="text-titlebg">
                所属计划节点
            </td>
            <td  >
                <div class="color-66 input-div" id="nodeNames"></div>
            </td>
        </tr>
        <tr>
            <td class="text-titlebg">计划起止时间
            </td>
            <td>
                <div class="color-66 input-div" id="beginDate"></div>
                <input name="id" id="planNodeId" class="mini-hidden"/>
            </td>

            <td class="text-titlebg">
                实际结束日期
            </td>
            <td>
                <div class="color-66 input-div" id="overDate"></div>
            </td>
        </tr>
    </table>
    <div class="title-info"><span>详细信息</span>
    </div>

    <div id="datagrid1" class="mini-datagrid" style="width:100%;height:280px; margin-top: 35px;" idField="id" url="/monthlyPlanExecution/fruitArchivesDetailedListByPage"
         allowResize="true" pageSize="20" allowCellEdit="true" allowCellSelect="true" multiSelect="true"  editNextOnEnterKey="true"  editNextRowCell="true">
        <div property="columns">
            <!--<div type="checkcolumn" allowResize="false" width="15"></div>-->
            <div type="indexcolumn" allowResize="false" width="15">编号</div>
            <div   field="id" name="id" hidden="true"  headerAlign="center" allowSort="true" allowResize="false">
                <input property="editor"   class="mini-hidden" style="width:100%;" minWidth="200" />
            </div>
            <div   field="achievementName" name="achievementName" headerAlign="center" allowSort="true" width="80" allowResize="false">成果名称
            </div>
            <div field="achievementNature" name="achievementNature"  width="80" headerAlign="center" allowSort="true" allowResize="false">成果性质
            </div>
            <div field="achievementTime"  name="achievementTime" renderer="view.ondayRenderer" headerAlign="center"  width="40" allowSort="true" allowResize="false">成果取得时间
            </div>
            <div field="patternManifestation"  name="patternManifestation" width="50" allowSort="true" allowResize="false">表现形式
            </div>
            <div field="storagePlace"  name="storagePlace" width="50" allowSort="true" allowResize="false">原始资料存放位置
            </div>
            <div   field="file_url" name="file_url" hidden="true"  headerAlign="center" allowSort="true" allowResize="false">
                <input property="editor" class="mini-hidden" style="width:100%;" minWidth="200" />
            </div>
            <div field="file_name" name="file_name"   headerAlign="center" allowSort="true" allowResize="false" renderer="view.onLoadFile">已上传文件 <!--  renderer="view.getFile" -->

            </div>

        </div>
    </div>
</div>
<script src="/scripts/res/js/common.js"></script>
<script type="text/javascript">
    var grid,form;
    //用于存储附件名
    var newData=[];
    var json;
    var view = {
        init:function () {
            mini.parse();
            grid = mini.get("datagrid1");
            form = new mini.Form("#editForm");
            //grid.load();
            grid.hideColumn("id");//隐藏列
            grid.hideColumn("file_url");//隐藏列
            grid.on("celleditenter", function(e) {
                var index = grid.indexOf(e.record);
                if (index == grid.getData().length - 1) {
                    var row = {};
                    grid.addRow(row);
                }
            });

            mini.get("datagrid1").load({"keyFruitArchives.id":8})
        },
        //格式化日期
        ondayRenderer: function(e) {
            if (e.value) {
                var value = new Date(e.value);
                if (value) {
                    return mini.formatDate(value, 'yyyy-MM-dd')
                }
            }else{
                return "";
            }
        },
        //回显数据
        SetData:function (data) {
            data = mini.clone(data);
            mini.get("planNodeId").setValue(data.id);
            i = data.id;
            //跨页面传递的数据对象，克隆后才可以安全使用
            $.ajax({
                url:"/monthlyPlanExecution/info?id=" + data.id,
                type: "post",
                success: function (text) {
                    var obj = JSON.parse(text);
                    //跨页面传递的数据对象，克隆后才可以安全使用
                    datas = mini.decode(obj.body[0]);   //反序列化成对象
                    // form.setData(datas);             //设置多个控件数据
                    var beDate;
                    $.each(datas,function (key,value) {
                        $("#"+key).html(value);
                        if(key=="beginDate"){
                            beDate=value;
                        }
                        if(key=="endDate"){
                            beDate=beDate+" ~ "+value;
                        }
                        if(key=="nodeName"){
                            $("#nodeNames").text(value);
                        }
                        $("#beginDate").text(beDate);
                    });
                    // mini.get("date-range1").setValue(datas.beginDate +" ~ " +datas.endDate)
                    
                }
            });
        },
        onLoadFile : function(e){
            var fileName;
        	$.ajax({
                url: "/fileCommon/loadFileList",
                type : "post",
                dataType: 'json',
                async: false,       //是否同步,默认true异步
                data:{"tableId":e.row.id,"tableName":"t_key_fruit_archives_detailed"},
            }).done(function(text) {
                if(text){
                    var listFile = text;
                    for(var i=0;i<listFile.length;i++ ){
                        var file = listFile[i];
                        var name =	"<a class='check-botton' onclick=\"list.downFile('" +file.fileUrl+"','"+file.fileName+"')\">" + file.fileName + "</a><br>";
                        if(!fileName){
                            fileName=name;
                        }else{
                            if(fileName){
                                fileName+=name;
                            }
                        }

                    }
                }
            });
            return fileName;
        	
        },
        downFile:function(url,name){
            window.location.href = "/ftp/downFile?path="+url+"&fileName="+name;
        }
    };
    view.init();
</script>
</body>
</html>